package com.bjdd.jdy.ui;

import android.content.Context;

import com.bjdd.jdy.base.BaseResult;
import com.bjdd.jdy.entity.User;
import com.bjdd.jdy.util.Api;
import com.bjdd.jdy.util.RxSchedulers;

import java.util.Set;

import cn.jpush.android.api.JPushInterface;
import cn.jpush.android.api.TagAliasCallback;
import rx.Observable;

/**
 * Created by yukai on 2016/11/13.
 */

public class MainModel implements MainContract.Model{


    @Override
    public Observable<BaseResult<User>> getUserInfo(String token, String userId) {
        return Api.getInstance().service
                .getUserInfo(token,userId)
                .compose(RxSchedulers.io_main());
    }

    @Override
    public Observable<String> setAlias(Context context,String alias) {
        JPushInterface.setAlias(context, alias, new TagAliasCallback() {
            @Override
            public void gotResult(int i, String s, Set<String> set) {
                if (i == 0){
                    return;
                }
            }
        });
        return null;
    }

    @Override
    public Observable upLoadPosition(String token, String carrierId, double lng, double lat) {

        return Api.getInstance().service
                .locations(token,carrierId,lng,lat)
                .compose(RxSchedulers.io_main());
    }
}
